package com.rst.validator;

import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.rst.model.InstituteDetail;


@Component("instituteDetailsFormValidator")
public class InstituteDetailsFormValidator implements Validator{

	@Override
	public boolean supports(@SuppressWarnings("rawtypes") Class clazz)
	{
		return InstituteDetail.class.isAssignableFrom(clazz);
	}

	@Override
	public void validate(Object model, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name","required.name", "Name is required.");
		
		InstituteDetail detail = (InstituteDetail) model;
/*		if(detail.getEmail() != ""){
			errors.rejectValue("mobile", "notmatch.mobile");
		}
*/
	}

}
